<script>
import MixLineChart2 from './MixLineChart2'

export default {
  extends: MixLineChart2,
  data() {
    return {
      op: {
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'shadow' // 默认为直线，可选为：'line' | 'shadow'
          },
          formatter: function(params) {
            var res = '<center>' + params[0].axisValue + '</center>'
            for (var i = 0; i < params.length; i++) {
              res += params[i].marker + params[i].seriesName + ' : ' + params[i].value + '%' + '<br>'
            }
            return res
          }
        }
      }
    }
  },
  methods: {
    test(cData) {
      const series = []
      const series_data = this.chartData.series_data
      if (cData) {
        if (cData.length !== 0) {
          cData.forEach(function(item) {
            series.push({
              name: item,
              type: 'line',
              // stack: '总量',y轴显示会不一致
              barMaxWidth: 35,
              barGap: '10%',
              itemStyle: {
                normal: {
                  label: {
                    show: true,
                    position: 'top',
                    formatter(p) {
                      return p.value + '%'
                    }
                  }
                }
              },
              smooth: true,
              lineStyle: {
                width: 2
              },
              data: series_data[item]
            })
          })
          this.showSeries = series
        }
      }
    }
  }
}
</script>
